package com.caifu.mapper;

import com.caifu.pojo.YlBedRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

/**
 * <p>
 * 床位更换记录表 Mapper 接口
 * </p>
 *
 * @author GZ
 * @since 2020-11-06
 */
public interface YlBedRecordMapper extends BaseMapper<YlBedRecord> {

    @Select({"<script>",
        "SELECT b.BUILDING_NAME,f.FLOOR_NAME,rm.ROOM_NAME,bed.BED_NAME FROM yl_bed_record r ",
         "left join yl_building b on r.BUILDING_NO = b.BUILDING_NO LEFT JOIN yl_floor f on r.FLOOR_NO=f.FLOOR_NO",
            "left join yl_room rm on r.ROOM_NO=rm.ROOM_NO left join yl_bed bed on r.BED_NO = bed.BED_NO",
            "where r.USER_NO = #{userNo}",
            "and r.is_effective='1'",
    "</script>"})
    Map<String,Object> queryOldUserBedInfo(@Param("userNo") String userNo);
    /**
    * 
    * 功能描述：查询老人在养老院的床位信息
    * 
    * @Param userNo 老人编号
    * @Return      
    * @Exception   
    * @Author  GZ
    * @Date   2020/11/25 11:33
    */
    @Select({"<script>",
            "SELECT CONCAT_WS('-',b.BUILDING_NAME,rm.ROOM_NAME,bed.BED_NAME) FROM yl_bed_record r ",
            "left join yl_building b on r.BUILDING_NO = b.BUILDING_NO LEFT JOIN yl_floor f on r.FLOOR_NO=f.FLOOR_NO",
            "left join yl_room rm on r.ROOM_NO=rm.ROOM_NO left join yl_bed bed on r.BED_NO = bed.BED_NO",
            "where r.USER_NO = #{userNo}",
            "and r.is_effective='1'",
            "</script>"})
    String queryOldUserBedName(@Param("userNo") String userNo);
}
